package com.demo.infrastructure.gateway;

import com.demo.infrastructure.gateway.dto.CSDNArticleRequest;
import com.demo.infrastructure.gateway.dto.CSDNArticleResponse;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.Header;

/**
 * CSDN 服务接口，使用 retrofit2 框架封装对 CSDN API 的调用
 */
public interface ICSDNService {

    /**
     * 保存文章到 CSDN
     * @param cookie 用户登录凭证，通过请求头传递
     * @param articleRequest 文章请求参数
     * @return 文章保存响应
     */
    @Headers({
            "accept: */*",
            "accept-language: zh-CN,zh;q=0.9",
            "content-type: application/json",
            "origin: https://editor.csdn.net",
            "priority: u=1, i",
            "referer: https://editor.csdn.net/",
            "sec-ch-ua: \"Google Chrome\";v=\"141\", \"Not?A_Brand\";v=\"8\", \"Chromium\";v=\"141\"",
            "sec-ch-ua-mobile: ?0",
            "sec-ch-ua-platform: \"Windows\"",
            "sec-fetch-dest: empty",
            "sec-fetch-mode: cors",
            "sec-fetch-site: same-site",
            "user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36",
            "x-ca-key: 203803574",
            "x-ca-nonce: 035138b7-6bed-4310-949d-dbab35a2e2c7",
            "x-ca-signature: eQX8AIpC3aWCRQQXRQ8oe2HpjeBGjs2OB3F4g66q49k=",
            "x-ca-signature-headers: x-ca-key,x-ca-nonce"
    })
    @POST("blog-console-api/v3/mdeditor/saveArticle")
    Call<CSDNArticleResponse> saveArticle(@Header("Cookie") String cookie, @Body CSDNArticleRequest articleRequest);
}
